package com.zhz.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 
 * @date ：Created in 2021/02/07
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description:
 **/
@Configuration
public class TopicConfig {
    //队列
    @Bean
    public Queue topicQ1(){
        return new Queue("topic_sb_mq_q1");
    }
    @Bean
    public Queue topicQ2(){
        return new Queue("topic_sb_mq_q2");
    }
    //交换机
    @Bean
    public TopicExchange setTopicExchange(){
        return new TopicExchange("topicExchange");
    }

    //绑定交换机和队列,声明binding，需要声明一个routingKey
    @Bean
    public Binding bindTopic1(){
        return BindingBuilder.bind(topicQ1()).to(setTopicExchange()).with("changsha.*");
    }
    @Bean
    public Binding bindQ2(){
        return BindingBuilder.bind(topicQ2()).to(setTopicExchange()).with("#.beijing");
    }
}
